package xyz.quanguanjia.masterboy;
// MBDIntegrationAdapter.java

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class MBDIntegrationAdapter extends RecyclerView.Adapter<MBDIntegrationAdapter.ViewHolder> {

    private List<MBDIntegrationDetailModel> integrationDetails;

    public MBDIntegrationAdapter(List<MBDIntegrationDetailModel> integrationDetails) {
        this.integrationDetails = integrationDetails;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_cell_integration_detail, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        MBDIntegrationDetailModel detail = integrationDetails.get(position);

        String time = MBDTimeUtils.timeToCurrentTime(detail.getCreateTime());
        holder.createTimeTextView.setText(time);
        holder.integralNumberTextView.setText(detail.getIntegralNumber());
        holder.integralSourceTextView.setText(detail.getIntegralSource());
    }

    @Override
    public int getItemCount() {
        return integrationDetails.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        TextView createTimeTextView;
        TextView integralNumberTextView;
        TextView integralSourceTextView;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);

            createTimeTextView = itemView.findViewById(R.id.createTimeTextView);
            integralNumberTextView = itemView.findViewById(R.id.integralNumberTextView);
            integralSourceTextView = itemView.findViewById(R.id.integralSourceTextView);
        }
    }
}



